<%--
@author Tharanga Punchihewa
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<script type="text/javascript">
    $(document).ready(function() {

        var organizationNameEnLabel = "<br>" + document.getElementById("organizationNameEnLabel").value;
        var organizationNameSiLabel = "<br>" + document.getElementById("organizationNameSiLabel").value;
        var organizationNameTaLabel = "<br>" + document.getElementById("organizationNameTaLabel").value;
        var pls_enter_valid_email = "<br>" + document.getElementById("pls_enter_valid_email").value;
        var pls_enter_valid_phone_No = "<br>" + document.getElementById("pls_enter_valid_phone_No").value;
        var pls_enter_valid_NIC_No = "<br>" + document.getElementById("pls_enter_valid_NIC_No").value;
        var pls_enter_name_of_head_of_GO = "<br>" + document.getElementById("pls_enter_name_of_head_of_GO").value;
        var pls_enter_address_of_GO = "<br>" + document.getElementById("pls_enter_address_of_GO").value;


        $("#add-organization-from").validate({
            rules: {
                organizationNameEn: {
                    required:true
                },
                organizationNameSi: {
                    required:true
                },
                organizationNameTa: {
                    required:true
                },
                addressOfGOId:{
                    required:true
                },
                mobileId:{
                    phoneNo:true
                },
                emailIdHead:{
                    email:true
                } ,
                landPhoneId:{
                    phoneNo:true
                } ,//////

                usernameId:{
                    required: true
                },
                fullnameId:{
                    required: true
                },
                emailId:{
                    required: true,
                    email:true
                },
                mobileId:{
                    phoneNo:true
                },
                landPhoneId:{
                    phoneNo:true
                }
            },
            messages: {
                organizationNameEn:organizationNameEnLabel,
                organizationNameSi:organizationNameSiLabel,
                organizationNameTa:organizationNameTaLabel,
                addressOfGOId:pls_enter_address_of_GO,
                mobileId:pls_enter_valid_phone_No,
                emailIdHead:pls_enter_valid_email,
                landPhoneId:pls_enter_valid_phone_No,
                ///////////////
                uernameId:{
                    required: "<br>" + "Please enter a username"
                },
                fullnameId:{
                    required: "<br>" + "Please enter your full name"
                },
                emailId:{
                    required: "<br>" + "Please enter your email",
                    email:"<br>" + "Please enter a valid email"
                },
                mobileId:{
                    phoneNo:"<br>" + "Please specify a valid phone number"
                },
                landPhoneId:{
                    phoneNo:"<br>" + "Please specify a valid phone number"
                }


            }
        });
    });
</script>


<div id="org-info-module-home-title" class="module-home-title">
    <s:a href="home.do"><img src="${pageContext.request.contextPath}/images/home.png"
                                    alt="Organizational Information"><span>Home</span></s:a>
    <span class="module-title-breaker"> > </span>
    <s:a href="#"><img src="${pageContext.request.contextPath}/images/registration-form.png"
                       alt="Land Registration"><span><s:label
            value="%{getText('register_organization.label')}"/></span></s:a>
</div>
<div id="add-organization-from-outer" class="form-outer">
    <div class="page-title">
        <h2><s:label value="%{getText('register_organization.label')}"/></h2>
    </div>
    <s:form method="POST" id="add-organization-from">
        <fieldset>
            <table class="width-100">
                <tr>
                    <td colspan="3"><h2><s:label value="%{getText('organization_information.label')}"
                                                 cssClass="title"/></h2></td>
                </tr>


                <tr>
                    <td><s:label value="%{getText('name_of_the_organization_en.label')}"
                                 cssClass="mandatory-field"/></td>
                    <td colspan="2"><s:textarea cssClass="width-500-px" name="organization.organizationNameEn"
                                                id="organizationNameEn"/></td>
                </tr>
                <tr>
                    <td><s:label value="%{getText('name_of_the_organization_si.label')}"
                                 cssClass="mandatory-field"/></td>
                    <td colspan="2"><s:textarea cssClass="width-500-px" name="organization.organizationNameSi"
                                                id="organizationNameSi"/></td>
                </tr>
                <tr>
                    <td><s:label value="%{getText('name_of_the_organization_ta.label')}"
                                 cssClass="mandatory-field"/></td>
                    <td colspan="2"><s:textarea cssClass="width-500-px" name="organization.organizationNameTa"
                                                id="organizationNameTa"/></td>
                </tr>
                <tr>
                    <td colspan="3"><h2><s:label value="%{getText('contact_details_of_the_head_of_GO.label')}"
                                                 cssClass="sub-title"/></h2></td>
                </tr>
                <tr>
                    <td><s:label value="%{getText('title.label')}"/></td>
                    <td colspan="2"><s:radio name="headOfGO.title"
                                             list="#@java.util.HashMap@{'3':getText('rev.label'),'2':getText('ms.label'),'1':getText('miss.label'),'0':getText('mr.label')}"/></td>
                </tr>
                <tr>
                    <td><s:label value="%{getText('name.label')}"/></td>
                    <td colspan="2"><s:textarea cssClass="width-500-px" name="headOfGO.name" id="goNameId"/></td>
                </tr>
                <tr>
                    <td><s:label value="%{getText('designation.label')}"/></td>
                    <td colspan="2"><s:textarea cssClass="width-500-px" name="headOfGO.designation"
                                                id="goDesignation"/></td>
                </tr>
                <tr>
                    <td><s:label value="%{getText('address.label')}" cssClass="mandatory-field"/></td>
                    <td colspan="2"><s:textarea cssClass="width-500-px" name="contactOfHeadOfGO.address"
                                                id="addressOfGOId"/></td>
                </tr>
                <tr>
                    <td rowspan="2"><s:label value="%{getText('telephone.label')}"/></td>
                    <td><s:label value="%{getText('mobile.label')}"/></td>
                    <td><s:textfield name="contactOfHeadOfGO.mobile" id="mobileId"/></td>
                </tr>
                <tr>
                    <td><s:label value="%{getText('land_phone.label')}"/></td>
                    <td><s:textfield name="contactOfHeadOfGO.landPhone" id="landPhoneId"/></td>
                </tr>
                <tr>
                    <td><s:label value="%{getText('email.label')}"/></td>
                    <td colspan="2"><s:textfield name="contactOfHeadOfGO.email" id="emailIdHead"/></td>
                </tr>
            </table>
        </fieldset>
        <br>
        <%--===--%>
        <fieldset>
            <table class="width-100">
                <tr>
                    <td colspan="3"><h2><s:label value="%{getText('create_user.label')}"
                                                 cssClass="page-title"/></h2></td>
                </tr>

                <tr>
                    <td class="left-align"><s:label value="%{getText('user_name.label')}"
                                                    cssClass="mandatory-field"/></td>
                    <td colspan="2" class="left-align">
                        <s:if test="editMode==1">
                            <s:textfield name="registerUser.username" id="usernameId" readonly="true"/>
                        </s:if>
                        <s:else>
                            <s:textfield name="registerUser.username" id="usernameId"/>
                        </s:else>

                    </td>
                </tr>
                <tr>
                    <td class="left-align"><s:label value="%{getText('full_name.label')}"
                                                    cssClass="mandatory-field"/></td>
                    <td colspan="2" class="right-align">
                        <s:textarea name="registerUser.fullName" id="fullnameId" cssClass="width-450-px"/>
                    </td>
                </tr>
                <tr>
                    <td class="left-align"><s:label value="%{getText('address.label')}"/></td>
                    <td colspan="2" class="left-align">
                        <s:textarea name="registerUser.address" id="addressId" cssClass="width-450-px"/>
                    </td>
                </tr>
                <tr>
                    <td rowspan="2"><s:label value="%{getText('telephone.label')}"/></td>
                    <td><s:label value="%{getText('mobile.label')}"/></td>
                    <td><s:textfield name="registerUser.mobile" id="mobileId"/></td>
                </tr>
                <tr>
                    <td><s:label value="%{getText('land_phone.label')}"/></td>
                    <td><s:textfield name="registerUser.landPhone" id="landPhoneId"/></td>
                </tr>
                <tr>
                    <td class="left-align"><s:label value="%{getText('email.label')}" cssClass="mandatory-field"/></td>
                    <td colspan="2" class="left-align"><s:textfield name="registerUser.email" id="emailId"/></td>
                </tr>

                <tr>
                    <s:hidden name="organizationId"/>
                    <s:hidden name="userRoleId"/>
                </tr>
                <tr>
                    <td></td>
                    <td colspan="2">
                        <s:hidden name="editMode"/>
                        <s:hidden name="organization.id"/>

                        <s:if test="editMode==2">
                            <div class="form-button-div right-align">
                                <s:submit action="addOrganisationAndCreateORPIIUser"
                                          value="%{getText('register.label')}"/>
                                <s:submit cssClass="cancel" action="initRegisterOrganizationList"
                                          value="%{getText('back.label')}"/>
                            </div>
                        </s:if>

                        <s:hidden name="headOfGO.id"/>
                        <s:hidden name="contactOfHeadOfGO.id"/>
                    </td>
                </tr>

                    <%--===--%>
            </table>
        </fieldset>
    </s:form>
</div>
<s:hidden id="organizationNameEnLabel" value="%{getText('organization_name_en.label')}"/>
<s:hidden id="organizationNameSiLabel" value="%{getText('organization_name_si.label')}"/>
<s:hidden id="organizationNameTaLabel" value="%{getText('organization_name_ta.label')}"/>
<s:hidden id="pls_enter_name_of_head_of_GO" value="%{getText('pls_enter_name_of_head_of_GO.label')}"/>
<s:hidden id="pls_enter_valid_email" value="%{getText('pls_enter_valid_email')}"/>
<s:hidden id="pls_enter_valid_phone_No" value="%{getText('pls_enter_valid_phone_No')}"/>
<s:hidden id="pls_enter_valid_NIC_No" value="%{getText('pls_enter_valid_NIC_No')}"/>
<s:hidden id="pls_enter_address_of_GO" value="%{getText('pls_enter_address_of_GO.label')}"/>
<s:hidden id="pls_enter_due_date" value="%{getText('pls_enter_due_date.label')}"/>


